package com.kantboot.business.talent.domain.entity;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 技能等级条件
 * 条件分为：
 *  1、年龄下限
 *  2、从事本专业工作年满
 *  3、需要满足的技能等级
 *  4、获得 `需要满足的技能等级` 后的工作年满
 *  5、学历下限
 *  6、专业类别
 *  7、需要满足的职称等级
 *  8、获得需要 `满足的职称等级` 后的年满年限
 *  9、绩效考核满足分数
 *  10、`绩效考核满足分数`年满
 */
@Entity
@Getter
@Setter
@Table(name = "bus_talent_skill_level_condition")
@Accessors(chain = true)
@EntityListeners(AuditingEntityListener.class)
@DynamicUpdate
@DynamicInsert
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
public class BusTalentSkillLevelCondition implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;


    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "gmt_create")
    private Date gmtCreate;

    /**
     * 修改时间
     */
    @CreatedDate
    @Column(name = "gmt_modified")
    private Date gmtModified;

    /**
     * 技能等级id
     */
    @Column(name = "skill_level_id")
    private Long skillLevelId;

    /**
     * 显示的优先级
     * 优先级越高，显示越靠前
     */
    @Column(name = "t_priority")
    private Integer priority;

    /**
     * 年龄下限
     */
    @Column(name = "min_age")
    private Integer minAge;

    /**
     * 年龄上限
     */
    @Column(name = "max_age")
    private Integer maxAge;

    /**
     * 从事本系列工作最低年限
     */
    @Column(name = "work_years")
    private Integer workYears;

    /**
     * 需要满足的技能等级
     */
    @Column(name = "need_skill_level_id")
    private Long needSkillLevelId;

    /**
     * 获得 `需要满足的技能等级` 后的工作年满
     */
    @Column(name = "need_skill_level_work_years")
    private Integer needSkillLevelWorkYears;

    /**
     * 绩效考核满足分数
     */
    @Column(name = "performance_score")
    private BigDecimal performanceScore;

    /**
     * `绩效考核满足分数`年满
     */
    @Column(name = "performance_score_years")
    private Integer performanceScoreYears;

    /**
     * 对应的人才计划
     */
    @ManyToMany
    @JoinTable(name = "bus_talent_skill_level_condition_talent_plan",
            joinColumns = @JoinColumn(name = "skill_level_condition_id"),
            inverseJoinColumns = @JoinColumn(name = "talent_plan_id"))
    List<BusTalentPlan> talentPlans;

    /**
     * 需要的职称等级ID
     */
    @Column(name = "need_title_level_id")
    private Long needTitleLevelId;

    /**
     * 职称等级需要的年满
     */
    @Column(name = "need_title_level_work_years")
    private Integer needTitleLevelWorkYears;

    /**
     * 描述
     */
    @Column(name = "description",length = 5000)
    private String description;

    /**
     * 所需的学历
     */
    @Column(name = "edu_level_number")
    private Integer eduLevelNumber;

    /**
     * 取得学历后的年满
     */
    @Column(name = "edu_work_years")
    private Integer eduWorkYears;

    /**
     * 是否国外院校
     */
    @Column(name = "is_foreign_school")
    private Boolean isForeignSchool;

    /**
     * 是否需要判断教育专业和系列匹配
     */
    @Column(name = "is_need_check_edu_major_and_series")
    private Boolean isNeedCheckEduMajorAndSeries;
}
